#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i, j;
	int** ps = (int**)malloc(3 * sizeof(int*));
	if (ps == NULL)
	{
		perror("malloc");
		return 1;
	}
	for (i = 0; i < 3; i++)
	{
		ps[i] = (int**)malloc(5 * sizeof(int));
		if (ps[i] == NULL)
		{
			perror("malloc");
			for (j = 0; j < 5; j++)
			{
				free(ps[j]);
				
			}
			free(ps);
			return 1;
		}
	}
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 5; j++)
		{
			ps[i][j] = i * 5 + j;
			printf("%d ", ps[i][j]);
		}
		printf("\n");
	}
	for (i = 0; i < 3; i++)
	{
		free(ps[i]);
	}
	free(ps);
	ps = NULL;
	return 0;
}